package com.senlingspace.payment.config;

import com.lkl.laop.sdk.Config2;
import com.lkl.laop.sdk.LKLSDK;
import com.lkl.laop.sdk.exception.SDKException;
import com.senlingspace.payment.config.properties.LakalaProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 拉卡拉初始化配置
 *
 * @author lebronjames
 * @date 2024/07/15
 */
@Slf4j
@Configuration
public class LakalaConfig {

    @Autowired
    private LakalaProperties lakalaProperties;

    @Bean
    public void initializeLakala() throws SDKException {

        Config2 config = new Config2();
        config.setAppId(lakalaProperties.getAppId());
        config.setSerialNo(lakalaProperties.getSerialNo());
        config.setPriKey(lakalaProperties.getPrivateKey());
        config.setLklCer(lakalaProperties.getLklCer());
        config.setLklNotifyCer(lakalaProperties.getLklNotifyCer());
        config.setServerUrl(lakalaProperties.getServerUrl());

        LKLSDK.init(config);
        log.info("LKLSDK init successfully...");
    }

}
